Next: Comments, Up: Lisp Data Types [Contents][Index]
The printed representation of an object is the format
of the output generated by the Lisp printer (the function
prin1) for that object. Every data type has a unique
printed representation. The read syntax of an object is
the format of the input accepted by the Lisp reader (the function
read) for that object. This is not necessarily
unique; many kinds of object have more than one syntax. See
Read and
Print.
In most cases, an object’s printed representation is also a read syntax for the object. However, some types have no read syntax, since it does not make sense to enter objects of these types as constants in a Lisp program. These objects are printed in hash notation, which consists of the characters ‘#<’, a descriptive string (typically the type name followed by the name of the object), and a closing ‘>’. For example:
(current-buffer)
⇒ #<buffer objects.texi>
Hash notation cannot be read at all, so the Lisp reader
signals the error invalid-read-syntax whenever it
encounters ‘#<’.
In other languages, an expression is text; it has no other form. In Lisp, an expression is primarily a Lisp object and only secondarily the text that is the object’s read syntax. Often there is no need to emphasize this distinction, but you must keep it in the back of your mind, or you will occasionally be very confused.
When you evaluate an expression interactively, the Lisp
interpreter first reads the textual representation of it,
producing a Lisp object, and then evaluates that object (see
Evaluation). However,
evaluation and reading are separate activities. Reading returns
the Lisp object represented by the text that is read; the object
may or may not be evaluated later. See Input Functions, for a
description of read, the basic function for reading
objects.
Next: Comments, Up: Lisp Data Types [Contents][Index]